import router from './router'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style

NProgress.configure({ showSpinner: false }) // NProgress Configuration

router.beforeEach(async(to, from, next) => {
  NProgress.start()
  // document.title = getPageTitle(to.meta.title)
  next()
})

router.afterEach(() => {
  NProgress.done()
})

// function filterAsyncRouter(asyncRouterMap) {
//   const accessedRouters = asyncRouterMap.filter(route => {
//     if (route.component) {
//       if (route.component === 'Layout') {
//         route.component = Layout
//       } else {
//         const component = route.component
//         route.component = (resolve) => require([`@/views/${component}`], resolve)
//       }
//     }
//     if (route.children && route.children.length > 0) {
//       route.children = filterAsyncRouter(route.children)
//     }
//     return true
//   })
//   return accessedRouters
// }
